<?php

namespace app\home\business;





use TencentCloud\Sms\V20210111\SmsClient;
// 导入要请求接口对应的Request类
use TencentCloud\Sms\V20210111\Models\SendSmsRequest;
use TencentCloud\Common\Exception\TencentCloudSDKException;
use TencentCloud\Common\Credential;
// 导入可选配置类
use TencentCloud\Common\Profile\ClientProfile;
use TencentCloud\Common\Profile\HttpProfile;



class SendSms
{
    public static function sendInfo($code,$phone)
    {
        $app_id = config('sms.app_id');
        $app_key = config('sms.app_key');
        $template_id = config('sms.template_id');
        $sms_sign = config('sms.sms_sign');

        try {
            $sender = new \Qcloud\Sms\SmsSingleSender($app_id, $app_key);
            $params = [$code];
            $result = $sender->sendWithParam("86", $phone, $template_id,
                $params, $sms_sign, "", "");  // 签名参数未提供或者为空时，会使用默认签名发送短信
            $rsp = json_decode($result);
            if ($rsp->result == 0) {//0代表成功
                return '发送成功';
            }
            \think\facade\Log::error('发送短信验证码失败：' . $result);
        } catch (\Exception $e) {
        }
        return '发送失败';

    }
}